<style scoped>
.modal-wrapper {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1000;
	background-color: rgba(0, 0, 0, .5);
}
.modal-content {
	position: absolute;
	top: .8rem;
	right: 0;
	bottom: 0;
	left: 0;
	border-radius: .16rem .16rem 0 0;
	background-color: #FFF;
}
.modal-enter-active, .modal-leave-active {
	transition: all .3s;
}
.modal-enter, .modal-leave-to  {
	opacity: 0;
	transform: translateY(100%);
}
.modal-enter .hoc-modal-content {
	/* transform: scale(.9); */
}
/* .modal-content {
	width: 100%;
	height: 4rem;


	position: relative;
	box-sizing: border-box;
	background-color: #FFF;
	transition: all .2s;
} */
.title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 .3rem;
	color: rgba(0, 0, 0, .8);
	font-size: .38rem;
	line-height: .88rem;

	&::after {
		content: "1";
		opacity: 0;
	}
}
.close {
	width: .44rem;
	height: .44rem;
	background: url(~@/assets/task-close-2.png);
	background-size: 100% 100%;
}
.save-btn {
	position: absolute;
	left: .3rem;
	right: .3rem;
	bottom: .2rem;
	bottom: calc(.2rem + env(safe-area-inset-bottom));
	background-color: #00B2F8;
}
</style>

<template>
	<transition name="modal">
		<div class="modal-wrapper" v-if="show" @touchmove.prevent>
			<div class="modal-content">
				<h1 class="title">
					<span class="close" @click="$emit('change', false)"></span>
					{{title}}
				</h1>
				<slot name="content"></slot>
				<div class="btn save-btn" :class="{disabled: disabled}" v-if="isShowSaveBtn" @click="$emit('close')">保存</div>
			</div>
		</div>
	</transition>
</template>

<script>
	export default {
		name: 'action-sheet',

		props: {
			show: {
				type: Boolean
			},
			title: {
				type: String
			},
			isShowSaveBtn: {
				type: Boolean,
				default: true
			},
			disabled: {
				type: Boolean
			},
		},

		model: {
			prop: 'show',
			event: 'change'
		},

		methods: {
			handleEscModal() {
				document.addEventListener('keyup', this.$handleEscModal, false)
			},
			change(value) {
				this.$emit('change', value)
			}
		}
	}
</script>